package com.neusoft.a312cxy.android18cxy.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.neusoft.a312cxy.android18cxy.R;
import com.neusoft.a312cxy.android18cxy.bean.Orderlist;

import java.util.List;

/**
 * Created by Young on 2017/10/31.
 */

public class tuikuanAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<Orderlist> mDataList1;
    private LayoutInflater mLayoutInflater;


    public tuikuanAdapter(Context mContext, List<Orderlist> mDataList) {
        this.mContext = mContext;
        this.mDataList1 = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public  tuikuanAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.inflate(R.layout.cardview_weiwancheng, parent, false);
        return new tuikuanAdapter.ViewHolder(v);


    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final Orderlist entity =  mDataList1.get(position);
        if (null == entity)
            return;
        tuikuanAdapter.ViewHolder viewHolder = (tuikuanAdapter.ViewHolder) holder;
        viewHolder.price.setText(entity.getPrice());
        viewHolder.name.setText(entity.getName());
        //viewHolder.type.setText(entity.getType());
        if(entity.getType().equals("1")){
            viewHolder.type.setText("活动订单");
        }
        else if(entity.getType().equals("2")){
            viewHolder.type.setText("培训订单");

        }
        else if (entity.getType().equals("3")){
            viewHolder.type.setText("课程订单");
        }
        viewHolder.orderid.setText(entity.getId());




    }

    @Override
    public int getItemCount() {
        return mDataList1.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        // ImageView photo;
        TextView price, name,type,orderid;




        public ViewHolder(View itemView) {
            super(itemView);
            //    photo= (ImageView) itemView.findViewById(R.id.photo);
            price = (TextView) itemView.findViewById(R.id.price);
            name= (TextView) itemView.findViewById(R.id.name);
            type=(TextView) itemView.findViewById( R.id.type);
            orderid=(TextView) itemView.findViewById( R.id.id);



        }
    }
}
